package com.wst.wst_server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wst.wst_server.entity.Orgplus;
import com.wst.wst_server.mapper.OrgplusMapper;
import com.wst.wst_server.service.IOrgplusService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyk
 * @since 2023-03-24
 */
@Service
public class OrgplusServiceImpl extends ServiceImpl<OrgplusMapper, Orgplus> implements IOrgplusService {
    @Autowired
    OrgplusMapper orgplusMapper;
    @Override
    public List<Orgplus> getbyorgid(Map<String, Object> map) {
        QueryWrapper queryWrapper = new QueryWrapper<Orgplus>().orderByDesc("id");
        if(!(Integer.parseInt(map.get("orgId[0]").toString())==0 && map.size() == 2) ){
            List<Integer> ids =new ArrayList<>();
            Set<String> keys = map.keySet();
            for (String key : keys){
                ids.add(Integer.parseInt(map.get(key).toString()));
            }
            queryWrapper.in("orgid",ids);
        }
        return orgplusMapper.selectList(queryWrapper);
    }
}
